package com.zxy.demo.junit.runners;

import com.zxy.demo.junit.runners.AttributeFun;
import com.zxy.demo.junit.runners.Person;
import com.zxy.demo.junit.runners.PersonImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

/**
 * PersonTest.
 *
 * Created by zxybird on 17/5/15.
 */
public class PersonTest {

  private Person person;

  @Before
  public void buildPerson()
  {
    person = new PersonImpl("Willard", 3);
  }


  @Category(AttributeFun.class)
  @Test
  public void testGetAge() {
    int age = person.getAge();
    assertEquals(3, age);
  }

  @Category(AttributeFun.class)
  @Test
  public void testGetName() {
    String name = person.getName();
    assertEquals("Willard", name);
  }

  @Category(BehaviorFun.class)
  @Test
  public void testTalk() {
    String message = person.talkTo("Jimy");
    assertNotNull(message);
  }

  @Category(BehaviorFun.class)
  @Test(timeout = 200)
  public void testWalk() {
    person.walk();
  }

}
